<?php
class cidade_model extends CI_Model {
    
    private $table = 'tb_cidade';
    
    public function __construct() {
        parent::__construct();
    }
    
    function update($id, $event) {
        $this->db->where('cid_codigo', $id);
        $this->db->update($this->table, $event);
    }

    function delete($id) {
        $this->db->where('cid_codigo', $id);
        $this->db->delete($this->table);
    }

    function insert($event) {
        $this->db->insert($this->table, $event);
    }

    function getAll() {
        $q = $this->db->query("select * from tb_cidade");
        $res = $q->result_array();
        return $res;
    }

    function getById($id) {
        $q = $this->db->query("select * from $this->table where cid_codigo = $id");
        $res = $q->result_array();
        return $res[0];
    }
}

?>
